<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>搜索建议补全</title>
    <script src="../static/jquery-3.5.1.js"></script>
</head>
<body>
    <div>
        <form>
            <input type="text" name="keyword" id="search" value="" autocomplete="off">
            <button>搜索</button>
        </form>
    </div>

    <div id="suggest">
        <p>搜索建议词</p>

    </div>
</body>
<script type="text/javascript">
    $("input[name='keyword']").keyup(function () {
        var url = '/control/es.php';
        var data = {keyword : $(this).val()};
        $.get(url, data, function (rs) {
            rs = JSON.parse(rs);
            if (rs.status == 0) {
                var html = '';
                $.each(rs.data, function (index, value) {
                    html += '<p>'+ value +'</p>';
                })
                $("#suggest").html(html);
            }
        });
    });


</script>
</html>
